﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace AnyLink.PosClient.Controls
{
    /// <summary>
    /// 图片按钮
    /// </summary>
    public class ImageButton : Button
    {
        static ImageButton()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton), new FrameworkPropertyMetadata(typeof(ImageButton)));
        }

        public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(ImageButton));
        /// <summary>
        /// 标题
        /// </summary>
        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(ImageButton) , new FrameworkPropertyMetadata(null));
        /// <summary>
        /// 方向
        /// </summary>
        public Orientation Orientation
        {
            get { return (Orientation)GetValue(OrientationProperty); }
            set { SetValue(OrientationProperty, value); }
        }

        public static readonly DependencyProperty HorizontalTitleAlignmentProperty = DependencyProperty.Register("HorizontalTitleAlignment"
            , typeof(HorizontalAlignment)
            , typeof(ImageButton)
            , new FrameworkPropertyMetadata(null));
        /// <summary>
        /// 标题水平对齐方式
        /// </summary>
        [Bindable(true), Category("Layout")]
        public HorizontalAlignment HorizontalTitleAlignment
        {
            get { return (HorizontalAlignment)GetValue(HorizontalTitleAlignmentProperty); }
            set { SetValue(HorizontalTitleAlignmentProperty, value); }
        }

        public static readonly DependencyProperty VerticalTitleAlignmentProperty = DependencyProperty.Register("VerticalTitleAlignment",typeof(VerticalAlignment),typeof(ImageButton), new FrameworkPropertyMetadata(null));
        /// <summary>
        /// 标题垂直对齐方式
        /// </summary>
        [Bindable(true), Category("Layout")]
        public VerticalAlignment VerticalTitleAlignment
        {
            get { return (VerticalAlignment)GetValue(VerticalTitleAlignmentProperty); }
            set { SetValue(VerticalTitleAlignmentProperty, value); }
        }

        public static readonly DependencyProperty MouseOverBackgroundProperty = DependencyProperty.Register("MouseOverBackground", typeof(Brush), typeof(ImageButton), new FrameworkPropertyMetadata(null));

        /// <summary>
        /// 鼠标悬浮背景色
        /// </summary>
        public Brush MouseOverBackground
        {
            get
            {
                return (Brush)this.GetValue(ImageButton.MouseOverBackgroundProperty);
            }
            set
            {
                this.SetValue(ImageButton.MouseOverBackgroundProperty, value);
            }
        }

        public static readonly DependencyProperty MousePressedBackgroundProperty = DependencyProperty.Register("MousePressedBackground", typeof(Brush), typeof(ImageButton), new FrameworkPropertyMetadata(null));
        /// <summary>
        /// 鼠标按下背景色
        /// </summary>
        public Brush MousePressedBackground
        {
            get
            {
                return (Brush)this.GetValue(ImageButton.MousePressedBackgroundProperty);
            }
            set
            {
                this.SetValue(ImageButton.MousePressedBackgroundProperty, value);
            }
        }

        public static readonly DependencyProperty UnEnabledBackgroundProperty = DependencyProperty.Register("UnEnabledBackground", typeof(Brush), typeof(ImageButton), new FrameworkPropertyMetadata(null));
        /// <summary>
        /// 未启用背景色
        /// </summary>
        public Brush UnEnabledBackground
        {
            get
            {
                return (Brush)this.GetValue(ImageButton.UnEnabledBackgroundProperty);
            }
            set
            {
                this.SetValue(ImageButton.UnEnabledBackgroundProperty, value);
            }
        }

        public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ImageButton), new FrameworkPropertyMetadata(null));

        /// <summary>
        /// 圆角
        /// </summary>
        public CornerRadius CornerRadius
        {
            get
            {
                return (CornerRadius)this.GetValue(ImageButton.CornerRadiusProperty);
            }
            set
            {
                this.SetValue(ImageButton.CornerRadiusProperty, value);
            }
        }


        /// <summary>
        /// 鼠标悬浮前景色
        /// </summary>
        public Brush MouseOverForeground
        {
            get { return (Brush)GetValue(MouseOverForegroundProperty); }
            set { SetValue(MouseOverForegroundProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MouseOverForegroundProperty =
            DependencyProperty.Register("MouseOverForeground", typeof(Brush), typeof(ImageButton));


        /// <summary>
        /// 透明度模式
        /// </summary>
        public bool IsOpacityMode
        {
            get { return (bool)GetValue(IsOpacityModeProperty); }
            set { SetValue(IsOpacityModeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for IsOpacityMode.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsOpacityModeProperty =
            DependencyProperty.Register("IsOpacityMode", typeof(bool), typeof(ImageButton), new PropertyMetadata(false));


        /// <summary>
        /// 鼠标悬浮透明度
        /// </summary>
        public double MouseOverOpacity
        {
            get { return (double)GetValue(MouseOverOpacityProperty); }
            set { SetValue(MouseOverOpacityProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MouseOverOpacity.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MouseOverOpacityProperty =
            DependencyProperty.Register("MouseOverOpacity", typeof(double), typeof(ImageButton), new PropertyMetadata(0.8));


    }
}
